{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            {foreach name="field" item="r"}
            <!--文字-->
            {if $r['is_status'] == '1' && $r['type'] == 'text'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="{$r.field}" value="{$data[$r['field']]|default=''}" autocomplete="off" placeholder="请输入{$r.name}" class="layui-input" {if $r.is_required == '1'}lay-verify="required"{/if}>
                </div>
            </div>
            <!--日期-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'date'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="{$r.field}" class="layui-input" id="birthday" value="{$data[$r['field']]|default=date('Y-m-d')}" placeholder="" autocomplete="off" {if $r.is_required == '1'}lay-verify="required"{/if}>
                </div>
            </div>
            <!--标签-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'tag'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <input id="demoTagsInput3" name="{$r.field}" value="{$data[$r['field']]|default=''}" {if $r.is_required == '1'}lay-verify="required"{/if} class="layui-hide"/>
                </div>
            </div>
            <!--状态-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'status'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <select name="{$r.field}" lay-search {if $r.is_required == '1'}lay-verify="required"{/if}>
                        <option value="">请选择{$r.name}</option>
                        {foreach name="status" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.status eq $v.name"}selected="selected"{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <!--类别-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'category'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <select name="{$r.field}_id" lay-search {if $r.is_required == '1'}lay-verify="required"{/if}>
                        <option value="">请选择{$r.name}</option>
                        {foreach name="category" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.category_id eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <!--来源-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'from'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <select name="{$r.field}_id" lay-search {if $r.is_required == '1'}lay-verify="required"{/if}>
                        <option value="">请选择{$r.name}</option>
                        {foreach name="from" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.from_id eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <!--行业-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'industry'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <select name="{$r.field}_id" lay-search {if $r.is_required == '1'}lay-verify="required"{/if}>
                        <option value="">请选择{$r.name}</option>
                        {foreach name="industry" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.industry_id eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <!--行业-->
            {elseif $r['is_status'] == '1' && $r['type'] == 'image'}
            <div class="layui-form-item">
                <label class="layui-form-label">{$r.name}</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="image" value="{$data.image|default=''}" autocomplete="off" placeholder="请上传{$r.name}" class="layui-input">
                    <button type="button" class="layui-btn layui-btn-position ajax-images"><i class="fa fa-file-image-o"></i> 选择{$r.name}</button>
                </div>
            </div>
            {elseif $r['is_status'] == '1' && $r['type'] == 'address'}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">省市</label>
                <div class="layui-input-inline" style="width:400px">
                    <input id="demoCascader1" name="shengshi" value="{$data.province|default=''},{$data.city|default=''},{$data.area|default=''}" placeholder="请选择" {if $r.is_required == '1'}lay-verify="required"{/if} class="layui-hide"/>
                    <input name="province" type="hidden"><input name="city" type="hidden"><input name="region" type="hidden">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">地址</label>
                <div class="layui-input-inline" style="width:400px">
                    <body onload="init()"></body>
                    <input type="text" name="address" id="place" value="{$data.address|default=''}" {if $r.is_required == '1'}lay-verify="required"{/if} class="layui-input" autocomplete="off">
                    <input type="hidden" name="lat"  id="latitude" value="{$data.lat|default=''}" autocomplete="off" class="layui-input">
                    <input type="hidden" name="lng" id="longitude" value="{$data.lng|default=''}" autocomplete="off" class="layui-input">
                    <span id="city"></span>
                    <div id="container" style="height:400px;"></div>
                </div>
            </div>
            {/if}
            {/foreach}
            <div class="layui-form-item">
                <label class="layui-form-label">客服</label>
                <div class="layui-input-inline" style="width:400px">
                    <select name="user_id" lay-search lay-verify="required">
                    {foreach name="user" item="v"}
                    <option value="{$v.id}" {if condition="isset($data) and $data.user_id eq $v.id"}selected="selected"{elseif UserId() eq $v.id}selected="selected"{/if}>{$v.name}</option>
                    {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="/static/hqui/module/cascader/citys-data.js"></script>
<script>
    layui.use(['cascader'], function () {
        var $ = layui.jquery;
        var cascader = layui.cascader;
        var admin = layui.admin;

        // value也是中文而不是区号
        var data = cascader.getCityData(admin.util.deepClone(citysData));
        cascader.render({
            elem: '#demoCascader1',
            data: data
        });

    });
    laydate.render({
        elem: '#birthday'
        ,trigger:'click'
    });
    layui.use(['jquery', 'tagsInput'], function () {
        var $ = layui.jquery;
        var tagsInput = layui.tagsInput;
        // BackSpace键可删除标签
        $('#demoTagsInput3').tagsInput({removeWithBackspace: true});
    });
</script>

<!-- 地图 -->
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=VSDBZ-NQEKS-LV6ON-6RRBY-V4PBQ-PXFIG&libraries=place"></script>
<script type="text/javascript" id="location" src="/static/js/location.js"  data-lat="{$data.lat|default=''}" data-lng="{$data.lng|default=''}"></script>
{/block}